/**
 * 
 */
package de.arnoldmedia.mybookshelf.connector;

import com.skype.SkypeException;
import com.skype.Stream;
import com.skype.StreamAdapter;

import de.arnoldmedia.mybookshelf.IMyBookshelf;

/**
 * @author aarnold
 *
 */
public class SkypeStreamAdapter extends StreamAdapter  {

	private IMyBookshelf mainApp = null;
	private Stream stream = null;
	
	public SkypeStreamAdapter(IMyBookshelf mA, Stream sm){
		
		this.mainApp = mA;
		this.stream = sm;
		
	}
	
	/* (non-Javadoc)
	 * @see com.skype.StreamListener#datagramReceived(java.lang.String)
	 */
	@Override
	public void datagramReceived(String receivedDatagram) throws SkypeException {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see com.skype.StreamListener#textReceived(java.lang.String)
	 */
	@Override
	public void textReceived(String receivedText) throws SkypeException {

		// pass message directly to lookUp method
		Integer idx = this.mainApp.lookUp(receivedText);

		// TODO replace test method
		if (idx>0)
			this.stream.write("gotcha!");
	}
}
